package com.example.springboot014blogadmin.exception;

import org.springframework.ui.Model;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @description: TODO
 * @author: uu
 * @data: 2023/7/9 下午 04:34
 * @version: v1.0
 */
/*
@ControllerAdvice
public class GlobalHandleException {
    @ExceptionHandler( BindException.class)
    public String handlerBindException(BindException bindException, Model model){
        BindingResult result = bindException.getBindingResult();
        if( result.hasErrors()){
            model.addAttribute("errors",result.getFieldErrors());
            System.out.println("result.getFieldErrors()="+result.getFieldErrors().size());
        }
        return "/blog/error/bind";
    }
    @ExceptionHandler( Exception.class)
    public String handlerDefaultException(Exception exception, Model model){
        model.addAttribute("msg","请稍后重试！！！");
        return "/blog/error/error";
    }
}
*/
